<?php
require 'settings.php';
require 'db.php';
?>

<html>
<head>
<title><?php echo $corp_name?> Industry Manager - Corporate pricelists</title>

<style type="text/css">
table, th, td
{
border: 1px solid black;
border-collapse: collapse;
padding: 5px;
}
</style>

</head>
<body>
<h1 class=c_page_title>Corporate pricelists</h1>
<table>
<tr><td style="font-weight:bold">Name</td><td style="font-weight:bold">Last update</td><td style="font-weight:bold">Markup</td><td style="font-weight:bold">Replacement discount</td><td style="font-weight:bold">Rounds to</td><td style="font-weight:bold">Location</td><td style="font-weight:bold">Action</td></tr>

<?php

$get_all_pricelists->bind_result( $pl_id, $pl_name, $pl_upd, $pl_markup, $pl_disc, $pl_round, $pl_location );
$get_all_pricelists->execute();

while( $get_all_pricelists->fetch() )
{
	$output = '<tr><td>'.$pl_name.'</td>';
	$output .= '<td>'.$pl_upd.'</td>';
	$output .= '<td>'.$pl_markup.'%</td>';
	$output .= '<td>'.$pl_disc.'%</td>';
	$output .= '<td>'.$pl_round.'</td>';
	$output .= '<td>'.$pl_location.'</td>';
	$output .= '<td>';
	$output .= '<form style="display:inline" id="view_pricelist" action="display_pricelist.php" method="post"><input type="submit" value="View" /><input name="pricelist_name" type="hidden" value="'.$pl_name.'" /><input name="pricelist_id" type="hidden" value="'.$pl_id.'" /></form>';
	$output .= '<form style="display:inline" id="delete_pricelist" action="delete_pricelist.php" method="post"><input type="submit" value="Delete" /><input name="pricelist_name" type="hidden" value="'.$pl_name.'" /><input name="pricelist_id" type="hidden" value="'.$pl_id.'" /></form>';
	$output .= '<form style="display:inline" id="edit_pricelist" action="edit_pricelist.php" method="post"><input type="submit" value="Edit" /><input name="pricelist_name" type="hidden" value="'.$pl_name.'" /><input name="pricelist_id" type="hidden" value="'.$pl_id.'" /></form>';
	$output .= '<form style="display:inline" id="materials_pricelist" action="materials_pricelist.php" method="post"><input type="submit" value="Materials..." /><input name="pricelist_name" type="hidden" value="'.$pl_name.'" /><input name="pricelist_id" type="hidden" value="'.$pl_id.'" /></form>';
	$output .= '</td></tr>';

	echo $output;
}

$get_all_pricelists->close();
?>

</table>

<br />
<a href="create_pricelist.php">Create a new pricelist</a><br />
<a href="index.php">Back to main screen</a>
</body>
</html>